#ifndef MYOPENGLWIDGET_H
#define MYOPENGLWIDGET_H

#include <QObject>
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLTexture>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer>

class MyOpenGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
    Q_OBJECT
public:
    MyOpenGLWidget(QWidget* parent = nullptr);
    ~MyOpenGLWidget();

    GLfloat pitch() { return m_pitch; }
    void setPitch(GLfloat pitch) { m_pitch = pitch; }

    GLfloat roll() { return m_roll; }
    void setRoll(GLfloat roll) { m_roll = roll; }

    GLfloat yaw() { return m_yaw; }
    void setYaw(GLfloat yaw) { m_yaw = yaw; }

protected:
    void initializeGL();
    void paintGL();
    void resizeGL(int width, int height);


private:
    QVector<GLfloat> m_vertices;
    QOpenGLShaderProgram m_shaderProgram;
    QOpenGLVertexArrayObject m_vao;
    QOpenGLBuffer m_vbo;
    QOpenGLBuffer m_cache;
    QOpenGLTexture* m_textures[6];

    GLfloat m_pitch, m_roll, m_yaw;
};

#endif // MYOPENGLWIDGET_H
